# 容联云发送短信工具
from ronglian_sms_sdk import SmsSDK
from django.conf import settings
import json
def send_message(tid, mobile, datas):
    ronglianyun = settings.RONGLIANYUN
    sdk = SmsSDK(ronglianyun.get("accId"),ronglianyun.get("accToken"),ronglianyun.get("appId"))
    # tid = 1
    # mobile = '15137842408'
    # datas = ('0066', '2')
    resp = sdk.sendMessage(tid, mobile, datas)
    jrs = json.loads(resp)
    # 判断短信是否发送成功
    if jrs.get("statusCode") ==  "000000":
        print('短信发送成功')
    else:
        print('短信发送失败')
        print(jrs.get('statusMsg'))
    return jrs.get('statusCode')